<!DOCTYPE html>
<html lang="en-us">
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">

    
    <meta property="og:site_name" content="Devean Blog">
    <meta property="og:type" content="article">

    
    <meta property="og:image" content="https://devean.cn/img/ladder-sky-bg.jpg">
    <meta property="twitter:image" content="https://devean.cn/img/ladder-sky-bg.jpg" />
    

    
    <meta name="title" content="机器学习 | 特征缩放" />
    <meta property="og:title" content="机器学习 | 特征缩放" />
    <meta property="twitter:title" content="机器学习 | 特征缩放" />
    

    
    <meta name="description" content="德文，程序员, 开源爱好者，生活探险家 | 这里是 德文 的博客，与你一起发现更大的世界。">
    <meta property="og:description" content="德文，程序员, 开源爱好者，生活探险家 | 这里是 德文 的博客，与你一起发现更大的世界。" />
    <meta property="twitter:description" content="德文，程序员, 开源爱好者，生活探险家 | 这里是 德文 的博客，与你一起发现更大的世界。" />
    

    
    <meta property="twitter:card" content="summary" />
    
    

    <meta name="keyword"  content="德文, Devean, DevonYe, 机器学习,量化金融, QuantitaTAtive Finance, 德文的网络日志, 德文的博客, Devean Blog, 博客, 个人网站, 互联网, Web, 云原生,微服务, Microservice">

    
    
    <meta name="baidu-site-verification" content="codeva-k4Gz4N5kH1" />
    
    <meta name="google-site-verification" content="5YbYjVsLhmXRSCU2u_xrAegZCOyvI296GhQyr-o9L9c" />


    <link rel="shortcut icon" href="/img/favicon.ico">

    <title>机器学习 | 特征缩放 | 德文的博客| Devean Blog</title>

    <link rel="canonical" href="/post/2023-11-11-machine-learning-feature-scaling/">

    
    
    
    <link rel="stylesheet" href="/css/bootstrap.min.css">

    
    <link rel="stylesheet" href="/css/hugo-theme-cleanwhite.min.css">

    
    <link rel="stylesheet" href="/css/zanshang.css">

    
    <link rel="stylesheet" href="/css/font-awesome.all.min.css">

    
    

    
    <script src="/js/jquery.min.js"></script>

    
    <script src="/js/bootstrap.min.js"></script>

    
    <script src="/js/hux-blog.min.js"></script>

    
    <script src="/js/lazysizes.min.js"></script>

    <script src="/js/bing-clarity.min.js"></script>

    
    
    
    
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/katex@0.16.3/dist/katex.min.css">
<script defer src="https://cdn.jsdelivr.net/npm/katex@0.16.3/dist/katex.min.js"></script>

<script defer src="https://cdn.jsdelivr.net/npm/katex@0.16.3/dist/contrib/auto-render.min.js" onload="renderMathInElement(document.body);"></script>
<script>
    document.addEventListener("DOMContentLoaded", function() {
        renderMathInElement(document.body, {
            delimiters: [
                {left: "$$", right: "$$", display: true},
                {left: "$", right: "$", display: false}
            ]
        });
    });
</script>
    

    
    
<script async src="https://www.googletagmanager.com/gtag/js?id=G-B430VD5TJ2"></script>
<script>
var doNotTrack = false;
if (!doNotTrack) {
	window.dataLayer = window.dataLayer || [];
	function gtag(){dataLayer.push(arguments);}
	gtag('js', new Date());
	gtag('config', 'G-B430VD5TJ2', { 'anonymize_ip': false });
}
</script>

    
</head>







<nav class="navbar navbar-default navbar-custom navbar-fixed-top">

    <div class="container-fluid">
        
        <div class="navbar-header page-scroll">
            <button type="button" class="navbar-toggle">
                <span class="sr-only">Toggle navigation</span>
                <span class="icon-bar"></span>
                <span class="icon-bar"></span>
                <span class="icon-bar"></span>
            </button>
            <a class="navbar-brand" href="/">Devean Blog</a>
        </div>

        
        
        <div id="huxblog_navbar">
            <div class="navbar-collapse">
                <ul class="nav navbar-nav navbar-right">
                    <li>
                        <a href="/">All Posts</a>
                    </li>
                    
                        
                        <li>
                            <a href="/categories/finance/">finance</a>
                        </li>
                        
                        <li>
                            <a href="/categories/life/">life</a>
                        </li>
                        
                        <li>
                            <a href="/categories/tech/">tech</a>
                        </li>
                        
                    
                    
		    
                        <li><a href="/archive//">ARCHIVE</a></li>
                    
                        <li><a href="/notes//">NOTES</a></li>
                    
                        <li><a href="/about//">ABOUT</a></li>
                    
		            <li>
                        <a href="/search"><i class="fa fa-search"></i></a>
		           </li>
                </ul>
            </div>
        </div>
        
    </div>
    
</nav>
<script>
    
    
    
    var $body   = document.body;
    var $toggle = document.querySelector('.navbar-toggle');
    var $navbar = document.querySelector('#huxblog_navbar');
    var $collapse = document.querySelector('.navbar-collapse');

    $toggle.addEventListener('click', handleMagic)
    function handleMagic(e){
        if ($navbar.className.indexOf('in') > 0) {
        
            $navbar.className = " ";
            
            setTimeout(function(){
                
                if($navbar.className.indexOf('in') < 0) {
                    $collapse.style.height = "0px"
                }
            },400)
        }else{
        
            $collapse.style.height = "auto"
            $navbar.className += " in";
        }
    }
</script>




<style type="text/css">
    header.intro-header {
        background-image: url('/img/ladder-sky-bg.jpg')
    }
</style>

<header class="intro-header" >

    <div class="container">
        <div class="row">
            <div class="col-lg-8 col-lg-offset-2 col-md-10 col-md-offset-1">
                <div class="post-heading">
                    <div class="tags">
                        
                        <a class="tag" href="/tags/machine-learning" title="Machine Learning">
                            Machine Learning
                        </a>
                        
                    </div>
                    <h1>机器学习 | 特征缩放</h1>
                    <h2 class="subheading">Machine Learning Feature Scaling</h2>
                    <span class="meta">
                        
                            Posted by 
                            
                                     &#34;Devean&#34;
                             
                            on 
                            Saturday, November 11, 2023
                            
                            
                            
                            
                    </span>
                </div>
            </div>
        </div>
    </div>
</header>




<article>
    <div class="container">
        <div class="row">

            
            <div class="
                col-lg-8 col-lg-offset-2
                col-md-10 col-md-offset-1
                post-container">

                
                <blockquote>
<p>本文从特征缩放概念、目的、常用特征缩放方法：最小-最大缩放、标准缩放、鲁棒缩放、L2 Normalization、L1 Normalization、Power Transformer的公式讲解、Python缩放数据可视化对比诠释了特征缩放</p>
</blockquote>
<h2 id="什么是特征缩放">什么是特征缩放</h2>
<p>特征缩放又称归一化，是机器学习中的一种技术，涉及调整数值数据的量度，使所有数据点在相似的尺度上。例如：身高、体重、年龄、收入等个人特征数据，每个维度的区间不一样，为保证所有维度的特征数据尺度一样，我们就需要对原始数据做特征缩放，将身高、体重、年龄、收入都转化为区间[0,1]之间的数据。</p>
<h2 id="为什么要做特征缩放">为什么要做特征缩放</h2>
<ul>
<li><strong>收敛速度</strong>：梯度下降等迭代方法在各特征尺度一致时会更快地收敛。</li>
<li><strong>避免数值不稳定性</strong>：在某些算法中，如果特征的尺度差异很大，可能会导致数值计算问题。</li>
<li><strong>更好的模型解释性</strong>：当所有特征都在同一个尺度上，它们的权重可以更容易地相互比较。</li>
</ul>
<h3 id="目的">目的</h3>
<ul>
<li><strong>使数据均匀</strong>：数据缩放通过将数据转换到新的尺度上，使不同特征间的数值大小差异减小。</li>
<li><strong>提高算法性能</strong>：缩放可以加快梯度下降的收敛速度，并提高算法（如支持向量机和 K 近邻算法）的性能。</li>
</ul>
<h2 id="特征缩放方法">特征缩放方法</h2>
<ol>
<li>
<p><strong>最小-最大缩放 (Min-Max Scaling)</strong></p>
<ul>
<li>公式: $X_{norm} =\frac {X - X_{min}}  {X_{max} - X_{min}}$</li>
<li>描述: 将数据缩放到[0,1]范围内的技术。</li>
<li>场景: 当数据分布不是高度偏斜，并且不包含极端值时。</li>
</ul>
</li>
<li>
<p><strong>标准化 (Standardization)</strong></p>
<ul>
<li>公式: $X_{standard} =\frac {(X - μ)}  σ$</li>
<li>描述: 通过使数据的平均值为 0，标准差为 1 来缩放数据。</li>
<li>场景：当算法需要数据的标准差为 1，且偏差很小时。</li>
</ul>
</li>
<li>
<p><strong>稳健缩放 (Robust Scaling)</strong></p>
<ul>
<li>公式: $X_{robust} =\frac {X - Q1} {Q3 - Q1}$</li>
<li>描述: 缩放技术，可以减少离群值的影响。</li>
<li>场景：当数据包含许多离群值或异常值时。</li>
</ul>
</li>
<li>
<p><strong>L2 Normalization (欧几里得范数)</strong></p>
<ul>
<li>公式: $X_{l2} =\frac {X - μ}  {||X||_2}$</li>
<li>描述: 通过使特征向量的欧几里得长度为 1 来缩放特征。</li>
<li>场景：在图像处理和文本分类中，当数据的方向比其大小更重要时。</li>
</ul>
</li>
<li>
<p><strong>L1 Normalization</strong></p>
<ul>
<li>公式: $X_{l1} =\frac {X - μ}  {||X||_1}$</li>
<li>描述: 通过使特征向量的欧几里得长度为 1 来缩放特征。</li>
<li>场景：在图像处理和文本分类中，当数据的方向比其大小更重要时。</li>
</ul>
</li>
<li>
<p><strong>Power Transformer</strong>
a. Box-Cox Transformation</p>
<ul>
<li>公式: $X_{Box-Cox} =\frac {X^{\lambda}-1} {\lambda},for \quad \lambda \neq 0,ln(X) \quad for \quad \lambda=0$</li>
<li>描述: Box-Cox 转换只能应用于正值的数据。它的目标是对非常数方差和非正态分布的数据进行变换，使其更接近正态分布。</li>
<li>场景：
<ul>
<li>线性模型：在回归、ANOVA 或设计实验中，当我们希望满足线性模型的正态分布假设时。</li>
<li>时间序列分析：稳定化时间序列数据的方差。</li>
<li>方差稳定化：在很多统计模型中，稳定的方差是关键。Box-Cox 转换能够稳定化方差，使其不随因变量的值而变化。</li>
<li>处理倾斜数据：对于正偏斜或负偏斜的数据，Box-Cox 转换可以帮助减少偏斜。</li>
</ul>
</li>
</ul>
<p>b. Yeo-Johnson Transformation</p>
<ul>
<li>公式：
$X_{yeo-Johnson}=\frac {(X+1)^{\lambda}-1} {\lambda} \quad for \quad \lambda \neq 0 \quad and \quad X \geq 0,ln(X+1) \quad for \quad\lambda=0 \quad and \quad X \geq 0，-\frac {(-X+1)^{\lambda}-1} {\lambda} \quad for \quad \lambda \neq 0 \quad and \quad X &lt; 0, -ln(-X+1) \quad for \quad \lambda=0 \quad and \quad X &lt;0$</li>
<li>描述: Yeo-Johnson 转换是 Box-Cox 的扩展，它可以应用于正值、负值和零的数据。这种转换同样旨在使数据更接近正态分布。</li>
<li>场景：
<ul>
<li>广义线性模型：当我们需要满足广义线性模型的正态分布假设时。</li>
<li>包含零或负值的数据：与 Box-Cox 不同，Yeo-Johnson 转换可以应用于包含零或负值的数据。</li>
<li>方差稳定化：与 Box-Cox 类似，Yeo-Johnson 转换也可以用来稳定化方差。</li>
<li>处理倾斜数据：对于正偏斜或负偏斜的数据，Yeo-Johnson 转换也是一个有效的工具。</li>
</ul>
</li>
</ul>
</li>
</ol>
<h2 id="数据缩放对比">数据缩放对比</h2>
<h3 id="原始数据">原始数据</h3>
<table>
<thead>
<tr>
<th>ID</th>
<th>身高(cm)</th>
<th>体重(kg)</th>
<th>心率(bpm)</th>
<th>胆固醇(mg/dL)</th>
<th>年龄</th>
<th>脚长(cm)</th>
</tr>
</thead>
<tbody>
<tr>
<td>1</td>
<td>170</td>
<td>68</td>
<td>75</td>
<td>180</td>
<td>25</td>
<td>25</td>
</tr>
<tr>
<td>2</td>
<td>160</td>
<td>50</td>
<td>80</td>
<td>200</td>
<td>30</td>
<td>23</td>
</tr>
<tr>
<td>3</td>
<td>180</td>
<td>77</td>
<td>72</td>
<td>220</td>
<td>28</td>
<td>27</td>
</tr>
<tr>
<td>4</td>
<td>175</td>
<td>65</td>
<td>78</td>
<td>210</td>
<td>32</td>
<td>26</td>
</tr>
<tr>
<td>5</td>
<td>166</td>
<td>58</td>
<td>82</td>
<td>190</td>
<td>29</td>
<td>24</td>
</tr>
</tbody>
</table>
<h3 id="python-代码">python 代码</h3>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#282a36;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-python" data-lang="python"><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span><span style="color:#ff79c6">import</span> pandas <span style="color:#ff79c6">as</span> pd
</span></span><span style="display:flex;"><span><span style="color:#ff79c6">import</span> numpy <span style="color:#ff79c6">as</span> np
</span></span><span style="display:flex;"><span><span style="color:#ff79c6">import</span> matplotlib.pyplot <span style="color:#ff79c6">as</span> plt
</span></span><span style="display:flex;"><span><span style="color:#ff79c6">from</span> sklearn.preprocessing <span style="color:#ff79c6">import</span> (MinMaxScaler, StandardScaler, RobustScaler,
</span></span><span style="display:flex;"><span>                                   MaxAbsScaler, QuantileTransformer, PowerTransformer)
</span></span><span style="display:flex;"><span><span style="color:#ff79c6">from</span> matplotlib.font_manager <span style="color:#ff79c6">import</span> FontProperties
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span><span style="color:#6272a4"># 设置中文字体路径</span>
</span></span><span style="display:flex;"><span>myFont <span style="color:#ff79c6">=</span> FontProperties(fname<span style="color:#ff79c6">=</span><span style="color:#f1fa8c">&#39;/System/Library/Fonts/PingFang.ttc&#39;</span>)
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span><span style="color:#6272a4"># Create the dataset</span>
</span></span><span style="display:flex;"><span>data <span style="color:#ff79c6">=</span> {
</span></span><span style="display:flex;"><span>    <span style="color:#f1fa8c">&#39;身高 (cm)&#39;</span>: [<span style="color:#bd93f9">170</span>, <span style="color:#bd93f9">175</span>, <span style="color:#bd93f9">168</span>, <span style="color:#bd93f9">180</span>, <span style="color:#bd93f9">172</span>],
</span></span><span style="display:flex;"><span>    <span style="color:#f1fa8c">&#39;体重 (kg)&#39;</span>: [<span style="color:#bd93f9">65</span>, <span style="color:#bd93f9">72</span>, <span style="color:#bd93f9">58</span>, <span style="color:#bd93f9">80</span>, <span style="color:#bd93f9">68</span>],
</span></span><span style="display:flex;"><span>    <span style="color:#f1fa8c">&#39;年龄&#39;</span>: [<span style="color:#bd93f9">25</span>, <span style="color:#bd93f9">30</span>, <span style="color:#bd93f9">28</span>, <span style="color:#bd93f9">35</span>, <span style="color:#bd93f9">29</span>],
</span></span><span style="display:flex;"><span>    <span style="color:#f1fa8c">&#39;脚长 (cm)&#39;</span>: [<span style="color:#bd93f9">25</span>, <span style="color:#bd93f9">26</span>, <span style="color:#bd93f9">25</span>, <span style="color:#bd93f9">27</span>, <span style="color:#bd93f9">26</span>],
</span></span><span style="display:flex;"><span>    <span style="color:#f1fa8c">&#39;收缩压 (mmHg)&#39;</span>: [<span style="color:#bd93f9">120</span>, <span style="color:#bd93f9">125</span>, <span style="color:#bd93f9">118</span>, <span style="color:#bd93f9">128</span>, <span style="color:#bd93f9">121</span>],
</span></span><span style="display:flex;"><span>    <span style="color:#f1fa8c">&#39;胆固醇 (mg/dL)&#39;</span>: [<span style="color:#bd93f9">190</span>, <span style="color:#bd93f9">200</span>, <span style="color:#bd93f9">185</span>, <span style="color:#bd93f9">210</span>, <span style="color:#bd93f9">195</span>],
</span></span><span style="display:flex;"><span>    <span style="color:#f1fa8c">&#39;心率 (bpm)&#39;</span>: [<span style="color:#bd93f9">70</span>, <span style="color:#bd93f9">72</span>, <span style="color:#bd93f9">68</span>, <span style="color:#bd93f9">75</span>, <span style="color:#bd93f9">71</span>]
</span></span><span style="display:flex;"><span>}
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>df <span style="color:#ff79c6">=</span> pd<span style="color:#ff79c6">.</span>DataFrame(data)
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span><span style="color:#6272a4"># Define a unique color for each feature</span>
</span></span><span style="display:flex;"><span>colors <span style="color:#ff79c6">=</span> plt<span style="color:#ff79c6">.</span>cm<span style="color:#ff79c6">.</span>Accent(np<span style="color:#ff79c6">.</span>linspace(<span style="color:#bd93f9">0</span>, <span style="color:#bd93f9">1</span>, <span style="color:#8be9fd;font-style:italic">len</span>(df<span style="color:#ff79c6">.</span>columns)))
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span><span style="color:#6272a4"># Scaling methods</span>
</span></span><span style="display:flex;"><span>scalars <span style="color:#ff79c6">=</span> {
</span></span><span style="display:flex;"><span>    <span style="color:#f1fa8c">&#39;原始数据&#39;</span>: <span style="color:#ff79c6">None</span>,
</span></span><span style="display:flex;"><span>    <span style="color:#f1fa8c">&#39;最小-最大 缩放器&#39;</span>: MinMaxScaler(),
</span></span><span style="display:flex;"><span>    <span style="color:#f1fa8c">&#39;标准缩放器&#39;</span>: StandardScaler(),
</span></span><span style="display:flex;"><span>    <span style="color:#f1fa8c">&#39;鲁棒缩放器&#39;</span>: RobustScaler(),
</span></span><span style="display:flex;"><span>    <span style="color:#f1fa8c">&#39;最大绝对值缩放器&#39;</span>: MaxAbsScaler(),
</span></span><span style="display:flex;"><span>    <span style="color:#f1fa8c">&#39;分位数转换器&#39;</span>: QuantileTransformer(n_quantiles<span style="color:#ff79c6">=</span><span style="color:#bd93f9">5</span>),
</span></span><span style="display:flex;"><span>    <span style="color:#f1fa8c">&#39;幂转换器&#39;</span>: PowerTransformer(method<span style="color:#ff79c6">=</span><span style="color:#f1fa8c">&#39;yeo-johnson&#39;</span>)
</span></span><span style="display:flex;"><span>}
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span><span style="color:#6272a4"># Determine the number of rows and columns for the subplots</span>
</span></span><span style="display:flex;"><span>n_features <span style="color:#ff79c6">=</span> <span style="color:#8be9fd;font-style:italic">len</span>(df<span style="color:#ff79c6">.</span>columns)
</span></span><span style="display:flex;"><span>n_scalars <span style="color:#ff79c6">=</span> <span style="color:#8be9fd;font-style:italic">len</span>(scalars)
</span></span><span style="display:flex;"><span>n_rows <span style="color:#ff79c6">=</span> n_features
</span></span><span style="display:flex;"><span>n_cols <span style="color:#ff79c6">=</span> n_scalars
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>fig, axes <span style="color:#ff79c6">=</span> plt<span style="color:#ff79c6">.</span>subplots(nrows<span style="color:#ff79c6">=</span>n_rows, ncols<span style="color:#ff79c6">=</span>n_cols, figsize<span style="color:#ff79c6">=</span>(<span style="color:#bd93f9">20</span>, <span style="color:#bd93f9">4</span> <span style="color:#ff79c6">*</span> n_features))
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span><span style="color:#ff79c6">for</span> row, feature <span style="color:#ff79c6">in</span> <span style="color:#8be9fd;font-style:italic">enumerate</span>(df<span style="color:#ff79c6">.</span>columns):
</span></span><span style="display:flex;"><span>    <span style="color:#ff79c6">for</span> col, (name, scaler) <span style="color:#ff79c6">in</span> <span style="color:#8be9fd;font-style:italic">enumerate</span>(scalars<span style="color:#ff79c6">.</span>items()):
</span></span><span style="display:flex;"><span>        ax <span style="color:#ff79c6">=</span> axes[row, col]
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>        <span style="color:#ff79c6">if</span> scaler:
</span></span><span style="display:flex;"><span>            scaled_data <span style="color:#ff79c6">=</span> scaler<span style="color:#ff79c6">.</span>fit_transform(df[[feature]])
</span></span><span style="display:flex;"><span>        <span style="color:#ff79c6">else</span>:
</span></span><span style="display:flex;"><span>            scaled_data <span style="color:#ff79c6">=</span> df[[feature]]<span style="color:#ff79c6">.</span>values
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>        ax<span style="color:#ff79c6">.</span>hist(scaled_data, bins<span style="color:#ff79c6">=</span><span style="color:#bd93f9">10</span>, color<span style="color:#ff79c6">=</span>colors[row], edgecolor<span style="color:#ff79c6">=</span><span style="color:#f1fa8c">&#39;black&#39;</span>)
</span></span><span style="display:flex;"><span>        <span style="color:#ff79c6">if</span> row <span style="color:#ff79c6">==</span> <span style="color:#bd93f9">0</span>:
</span></span><span style="display:flex;"><span>            ax<span style="color:#ff79c6">.</span>set_title(name, fontproperties<span style="color:#ff79c6">=</span>myFont)
</span></span><span style="display:flex;"><span>        <span style="color:#ff79c6">if</span> col <span style="color:#ff79c6">==</span> <span style="color:#bd93f9">0</span>:
</span></span><span style="display:flex;"><span>            ax<span style="color:#ff79c6">.</span>set_ylabel(feature, fontproperties<span style="color:#ff79c6">=</span>myFont, rotation<span style="color:#ff79c6">=</span><span style="color:#bd93f9">0</span>, labelpad<span style="color:#ff79c6">=</span><span style="color:#bd93f9">60</span>, ha<span style="color:#ff79c6">=</span><span style="color:#f1fa8c">&#39;right&#39;</span>)
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>fig<span style="color:#ff79c6">.</span>text(<span style="color:#bd93f9">0.5</span>, <span style="color:#bd93f9">0.01</span>, <span style="color:#f1fa8c">&#39;Value&#39;</span>, ha<span style="color:#ff79c6">=</span><span style="color:#f1fa8c">&#39;center&#39;</span>, fontproperties<span style="color:#ff79c6">=</span>myFont)
</span></span><span style="display:flex;"><span>fig<span style="color:#ff79c6">.</span>text(<span style="color:#bd93f9">0.01</span>, <span style="color:#bd93f9">0.5</span>, <span style="color:#f1fa8c">&#39;Frequency&#39;</span>, va<span style="color:#ff79c6">=</span><span style="color:#f1fa8c">&#39;center&#39;</span>, rotation<span style="color:#ff79c6">=</span><span style="color:#f1fa8c">&#39;vertical&#39;</span>, fontproperties<span style="color:#ff79c6">=</span>myFont)
</span></span><span style="display:flex;"><span><span style="color:#6272a4"># Adjust layout</span>
</span></span><span style="display:flex;"><span>plt<span style="color:#ff79c6">.</span>tight_layout(pad<span style="color:#ff79c6">=</span><span style="color:#bd93f9">1.0</span>)
</span></span><span style="display:flex;"><span>plt<span style="color:#ff79c6">.</span>subplots_adjust(top<span style="color:#ff79c6">=</span><span style="color:#bd93f9">0.90</span>,left<span style="color:#ff79c6">=</span><span style="color:#bd93f9">0.12</span>, wspace<span style="color:#ff79c6">=</span><span style="color:#bd93f9">0.4</span>, hspace<span style="color:#ff79c6">=</span><span style="color:#bd93f9">0.5</span>,bottom<span style="color:#ff79c6">=</span><span style="color:#bd93f9">0.08</span>)
</span></span><span style="display:flex;"><span>plt<span style="color:#ff79c6">.</span>suptitle(<span style="color:#f1fa8c">&#34;各特征在不同缩放方法下的分布&#34;</span>, fontproperties<span style="color:#ff79c6">=</span>myFont)
</span></span><span style="display:flex;"><span>plt<span style="color:#ff79c6">.</span>show()
</span></span></code></pre></div><h3 id="特征缩放图示">特征缩放图示</h3>
<p>
  <img src="https://picx.zhimg.com/70/v2-8c14f9c712e3377ac8a94917dc2ff8c5_1440w.avis?source=172ae18b&amp;biz_tag=Post" alt="1696885427440">

</p>
<blockquote>
<p>欢迎扫码关注公众号，订阅更多文章!</p>
</blockquote>
<p>
  <img src="/img/public-plantform-qr.png" alt="欢迎扫">

</p>

                
                
<div class="entry-shang text-center">
    
	    <p>「真诚赞赏，手留余香」</p>
	
	<button class="zs show-zs btn btn-bred">赞赏支持</button>
</div>
<div class="zs-modal-bg"></div>
<div class="zs-modal-box">
	<div class="zs-modal-head">
		<button type="button" class="close">×</button>
		<span class="author"><a href="https://devean.cn"><img src="/img/favicon.png" />Devean Blog</a></span>
        
	        <p class="tip"><i></i><span>真诚赞赏，手留余香</span></p>
		
 
	</div>
	<div class="zs-modal-body">
		<div class="zs-modal-btns">
			<button class="btn btn-blink" data-num="2">2元</button>
			<button class="btn btn-blink" data-num="5">5元</button>
			<button class="btn btn-blink" data-num="10">10元</button>
			<button class="btn btn-blink" data-num="50">50元</button>
			<button class="btn btn-blink" data-num="100">100元</button>
			<button class="btn btn-blink" data-num="1">任意金额</button>
		</div>
		<div class="zs-modal-pay">
			<button class="btn btn-bred" id="pay-text">2元</button>
			<p>使用<span id="pay-type">微信</span>扫描二维码完成支付</p>
			<img src="/img/reward/wechat-2.png"  id="pay-image"/>
		</div>
	</div>
	<div class="zs-modal-footer">
		<label><input type="radio" name="zs-type" value="wechat" class="zs-type" checked="checked"><span ><span class="zs-wechat"><img src="/img/reward/wechat-btn.png"/></span></label>
		<label><input type="radio" name="zs-type" value="alipay" class="zs-type" class="zs-alipay"><img src="/img/reward/alipay-btn.png"/></span></label>
	</div>
</div>
<script type="text/javascript" src="/js/reward.js"></script>

                

                
                <hr>
                <ul class="pager">
                    
                    <li class="previous">
                        <a href="/post/2023-11-12-machine-learning-k-nearest-neighbours/" data-toggle="tooltip" data-placement="top" title="机器学习 | K临近">&larr;
                            Previous Post</a>
                    </li>
                    
                    
                    <li class="next">
                        <a href="/post/2023-11-14-mathematical-applications-in-quantitative-finance/" data-toggle="tooltip" data-placement="top" title="翻译 | 量化金融中的数学应用">Next
                            Post &rarr;</a>
                    </li>
                    
                </ul>
                

                



            </div>

            
            
            <div class="
                col-lg-2 col-lg-offset-0
                visible-lg-block
                sidebar-container
                catalog-container">
                <div class="side-catalog">
                    <hr class="hidden-sm hidden-xs">
                    <h5>
                        <a class="catalog-toggle" href="#">CATALOG</a>
                    </h5>
                    <ul class="catalog-body"></ul>
                </div>
            </div>
            

            
            <div class="
                col-lg-8 col-lg-offset-2
                col-md-10 col-md-offset-1
                sidebar-container">

                
                
                <section>
                    <hr class="hidden-sm hidden-xs">
                    <h5><a href="/tags/">FEATURED TAGS</a></h5>
                    <div class="tags">
                        
                        
                        
                        <a href="/tags/machine-learning" title="machine-learning">
                            machine-learning
                        </a>
                        
                        
                        
                        <a href="/tags/quantitative-finance" title="quantitative-finance">
                            quantitative-finance
                        </a>
                        
                        
                        
                        
                    </div>
                </section>
                

                
                
                <section>
                    <hr>
                    <h5>FRIENDS</h5>
                    <ul class="list-inline">
                        
                        <li><a target="_blank" href=""></a></li>
                        
                    </ul>
                </section>
                
            </div>
        </div>
    </div>
</article>




<footer>
    <div class="container">
        <div class="row">
            <div class="col-lg-8 col-lg-offset-2 col-md-10 col-md-offset-1">
                <ul class="list-inline text-center">                  
                    
                    <li>
                        <a href="mailto:devean.ye@gmail.com">
                            <span class="fa-stack fa-lg">
                                <i class="fas fa-circle fa-stack-2x"></i>
                                <i class="fas fa-envelope fa-stack-1x fa-inverse"></i>
                            </span>
                        </a>
                    </li>
		           
                    
                    
                    <li>
                        <a target="_blank" href="https://www.zhihu.com/people/devonaha">
                            <span class="fa-stack fa-lg">
                                <i class="fas fa-circle fa-stack-2x"></i>
                                <i class="fab  fa-stack-1x fa-inverse">知</i>
                            </span>
                        </a>
                    </li>
		            
                    
                    

		            
                    
                    <li>
                        <a target="_blank" href="/img/wechat-QRCode.png">
                            <span class="fa-stack fa-lg">
                                <i class="fas fa-circle fa-stack-2x"></i>
                                <i class="fab fa-weixin fa-stack-1x fa-inverse"></i>
                            </span>
                        </a>
                    </li>
		            
                    
                    <li>
                        <a target="_blank" href="https://github.com/devon-ye">
                            <span class="fa-stack fa-lg">
                                <i class="fas fa-circle fa-stack-2x"></i>
                                <i class="fab fa-github fa-stack-1x fa-inverse"></i>
                            </span>
                        </a>
                    </li>
		            
                    
                    
                    
                    <li>
                        <a target="_blank" href="https://www.linkedin.com/in/yourlinkedinid">
                            <span class="fa-stack fa-lg">
                                <i class="fas fa-circle fa-stack-2x"></i>
                                <i class="fab fa-linkedin fa-stack-1x fa-inverse"></i>
                            </span>
                        </a>
                    </li>
		           
                    
                    
                    <li>
                        <a target="_blank" href="https://stackoverflow.com/users/7220519">
                            <span class="fa-stack fa-lg">
                                <i class="fas fa-circle fa-stack-2x"></i>
                                <i class="fab fa-stack-overflow fa-stack-1x fa-inverse"></i>
                            </span>
                        </a>
                    </li>
                    
                    
                    
                    
                    
            
            
            
           
                   <li>
                       <a href='' rel="alternate" type="application/rss+xml" title="Devean Blog" >
                           <span class="fa-stack fa-lg">
                               <i class="fas fa-circle fa-stack-2x"></i>
                               <i class="fas fa-rss fa-stack-1x fa-inverse"></i>
                           </span>
                       </a>
                   </li>
            
             </ul>
		<p class="copyright text-muted">
                    Copyright &copy; Devean Blog 2023
                    <br>
                    <a href="https://themes.gohugo.io/hugo-theme-cleanwhite">CleanWhite Hugo Theme</a> by <a href="https://zhaohuabing.com">Huabing</a> |
                    <iframe
                        style="margin-left: 2px; margin-bottom:-5px;"
                        frameborder="0" scrolling="0" width="100px" height="20px"
                        src="https://ghbtns.com/github-btn.html?user=zhaohuabing&repo=hugo-theme-cleanwhite&type=star&count=true" >
                    </iframe>
                </p>
            </div>
        </div>
    </div>
</footer>




<script>
    function loadAsync(u, c) {
      var d = document, t = 'script',
          o = d.createElement(t),
          s = d.getElementsByTagName(t)[0];
      o.src = u;
      if (c) { o.addEventListener('load', function (e) { c(null, e); }, false); }
      s.parentNode.insertBefore(o, s);
    }
</script>






<script>
    
    if($('#tag_cloud').length !== 0){
        loadAsync("/js/jquery.tagcloud.js",function(){
            $.fn.tagcloud.defaults = {
                
                color: {start: '#bbbbee', end: '#0085a1'},
            };
            $('#tag_cloud a').tagcloud();
        })
    }
</script>


<script>
    loadAsync("https://cdn.jsdelivr.net/npm/fastclick@1.0.6/lib/fastclick.min.js", function(){
        var $nav = document.querySelector("nav");
        if($nav) FastClick.attach($nav);
    })
</script>






<script type="text/javascript">
    function generateCatalog(selector) {

        
        
        
        
            _containerSelector = 'div.post-container'
        

        
        var P = $(_containerSelector), a, n, t, l, i, c;
        a = P.find('h1,h2,h3,h4,h5,h6');

        
        $(selector).html('')

        
        a.each(function () {
            n = $(this).prop('tagName').toLowerCase();
            i = "#" + $(this).prop('id');
            t = $(this).text();
            c = $('<a href="' + i + '" rel="nofollow">' + t + '</a>');
            l = $('<li class="' + n + '_nav"></li>').append(c);
            $(selector).append(l);
        });
        return true;
    }

    generateCatalog(".catalog-body");

    
    $(".catalog-toggle").click((function (e) {
        e.preventDefault();
        $('.side-catalog').toggleClass("fold")
    }))

    


    loadAsync("\/js\/jquery.nav.js", function () {
        $('.catalog-body').onePageNav({
            currentClass: "active",
            changeHash: !1,
            easing: "swing",
            filter: "",
            scrollSpeed: 700,
            scrollOffset: 0,
            scrollThreshold: .2,
            begin: null,
            end: null,
            scrollChange: null,
            padding: 80
        });
    });
</script>






</body>
</html>
